<template>
  <view class="job-list">
    <!-- 2025-7-26 黄玲说移除入口 
    <view
      class="jd-consultant jd-sect"
      @click="handleConsultantEntranceClick"
      v-if="showJDConsultant"
    >
      <view class="jd-consultant-container">
        <view class="market-icon">
          <img :src="consultant_entrance_hot" alt="" />
        </view>
        <view class="market-main-text">优化简历</view>
        <view class="market-sub-text">心仪offer，入职涨薪</view>
      </view>
      <view class="market-button">立即优化</view>
    </view> -->
    <JobItem
      v-for="(item, index) in data"
      :item="item"
      :props="props"
      :key="index"
      :positionId="positionId"
      :isEnterprisesActivityItem="isEnterprisesActivityItem"
    />
    <u-loadmore class="job-more" :status="status" :load-text="loadText" />
  </view>
</template>

<script>
import { getProductGroup, addBuryingPoint } from "@/api/modules/career.js";
import JobItem from "./JobItem.vue";
export default {
  props: {
    showJDConsultant: {
      type: Boolean,
      default: true,
    },
    data: {
      type: Array,
      default() {
        return [];
      },
    },
    positionId: {
      type: String,
      default() {
        return "";
      },
    },
    props: {
      type: Object,
      default() {
        return {
          title: "title",
          salary: "salary",
          cname: "cname",
          time: "time",
          region: "region",
          fldy: "fldy",
        };
      },
    },
    isEnterprisesActivityItem: {
      type: Boolean,
      default: false,
    },
    status: String,
  },
  components: {
    JobItem,
  },
  data() {
    return {
      productSign: "",
      consultant_entrance_hot:
        this.$imgBaseSelf + "careerPath/consultant_entrance_hot.png",
      loadText: {
        loadmore: "加载更多",
        loading: "加载中",
        nomore: "没有更多了",
      },
    };
  },
  created() {
    this.getProductGroup();
  },
  methods: {
    //普通的埋点
    async addBuryingPointFn(etId) {
      if (!this.personId) return;
      const params = {
        etId: etId,
        personId: uni.getStorageSync("person-id").slice(2) || "",
        cardType: this.cardType
          ? this.cardType
          : uni.getStorageSync("cardType") || this.cardType,
        consultantId: uni.getStorageSync("sellId")
          ? uni.getStorageSync("sellId")
          : "",
      };
      const res = await addBuryingPoint(params);
    },
    async getProductGroup() {
      const params = {
        personId: uni.getStorageSync("person-id").slice(2) || undefined,
        id: "1",
      };
      const res = await getProductGroup(params);
      if (res.code == 200 && Array.isArray(res.data) && res.data.length) {
        this.productSign = res.data[0].productSign;
      }
    },
    handleConsultantEntranceClick() {
      //职位首页咨询顾问按钮点击事件
      wx.reportEvent("job_index_consultant_click", {});
      this.addBuryingPointFn(20031);
      uni.navigateTo({
        url: `/pagesSub/userCenter/careerPathV2/components/CBuyPage?etId=20031`,
      });
      // switch (this.productSign) {
      //   case "CONSULTE_SERVICE":
      //     uni.navigateTo({
      //       url: `/pagesSub/userCenter/careerPathV2/components/BuyPage`,
      //     });
      //     break;
      //   case "ZHITU_WUHAN_SERVICE":
      //     uni.navigateTo({
      //       url: "/pagesSub/userCenter/careerPathV2/components/WuHanBuyPage",
      //     });
      //     break;
      //   case "ZHITU_TOC_SERVICE":
      //     uni.navigateTo({
      //       url: `/pagesSub/userCenter/careerPathV2/components/CBuyPage`,
      //     });
      //     break;
      //   default:
      //     break;
      // }
    },
  },
};
</script>

<style lang="scss">
@keyframes loading {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.job-list {
  .jd-consultant {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(349deg, #ffffff 0%, #ffffff 100%) !important;
    margin-bottom: 18rpx;
    padding: 16rpx !important;
    border-radius: 10rpx;

    &-container {
      display: flex;
      align-items: center;

      .market-icon {
        width: 54rpx;
        height: 54rpx;
        margin-right: 14rpx;

        img {
          width: 54rpx;
          height: 54rpx;
        }
      }

      .market-main-text {
        margin-right: 26rpx;
        font-family: PingFang-SC, PingFang-SC;
        font-weight: bold;
        font-size: 30rpx;
        color: #333333;
        line-height: 36rpx;
        text-align: left;
        font-style: normal;
      }

      .market-sub-text {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 24rpx;
        color: #666666;
        line-height: 32rpx;
        text-align: left;
        font-style: normal;
      }
    }

    .market-button {
      padding: 8rpx 28rpx;
      color: white;
      background: #f75a3e;
      font-size: 24rpx;
      border-radius: 28rpx;
      border: 3rpx solid #ffffff;
      font-weight: bold;
    }
  }

  .job-item {
    margin-bottom: 24rpx;
    padding: 32rpx;
    background: $uni-bg-color;
    border-radius: 24rpx;

    .item-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: $uni-font-size-lg;
      line-height: $uni-font-size-lg;
      font-weight: bold;

      .title {
        flex-grow: 1;
        margin-right: 24rpx;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }

      .salary {
        flex-shrink: 0;
        color: $u-type-primary;
      }
    }

    .item-middle {
      margin-top: 24rpx;
      font-size: $uni-font-size-sm;
      line-height: $uni-font-size-sm;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }

    .item-bottom {
      margin-top: 24rpx;
      font-size: $uni-font-size-sm;
      line-height: $uni-font-size-sm;
      color: $uni-text-color-555;

      .time {
        margin-right: 16rpx;
      }
    }
  }
}
</style>
